﻿using Prism.Ioc;
using Prism.Regions;
using RecordBill.Core;
using RecordBill.Data;
using RecordBill.Extensions;
using RecordBill.ViewModels;
using RecordBill.Views;
using System.Windows;

namespace RecordBill
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        protected override Window CreateShell()
        {
            var w= Container.Resolve<MainWindow>();
            w.Loaded += W_Loaded;
            return w;
        }

        private void W_Loaded(object sender, RoutedEventArgs e)
        {
           var regionManager = Container.Resolve<IRegionManager>();
            if (regionManager != null)
            {
                regionManager.RequestNavigate(PrismManager.RegionName, "HomeView");
            }
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterForNavigation<HomeView,HomeViewModel>();
            containerRegistry.RegisterForNavigation<BillTypeView, BillTypeViewModel>();
            containerRegistry.RegisterForNavigation<SettView, SettViewModel>();
            containerRegistry.RegisterForNavigation<BillStatisticsView, BillStatisticsViewModel>();
            containerRegistry.RegisterDialog<BillOtherClassifyView, BillOtherClassifyViewModel>();
            containerRegistry.RegisterScoped<ImportService>();
            containerRegistry.RegisterScoped<QQMailService>();
            

        }
    }
}
